import React, { Component } from 'react';
import './App.css';
import './assets/js/rem.js'
import Header from "./components/Header"
import Nav from "./components/Nav"
import Payfoot from "./components/Payfoot"
import Imported from "./components/Nav/Imported"
import Internal from "./components/Nav/Internal"
import Driedfd from "./components/Nav/Driedfd"
import Nut from "./components/Nav/Nut"
import Detail from "./components/Nav/Detail"
import Footer from "./components/Footer"
import Indexs from "./components/Footer/Indexs"
import Exchange from "./components/Footer/Exchange"
import Buycart from "./components/Footer/Buycart"
import Member from "./components/Footer/Member"
import {HashRouter,BrowserRouter,MemoryRouter,Route,Link,Switch,NavLink}from "react-router-dom"
class App extends Component {
  constructor(props){
    super(props)
    //console.log(Component.prototype)
    this.state={
      flag:true,
      isture:true
    }
   this.$bus.on("change",(val)=>{
     this.setState(state=>{
      state.flag=val
      return state
     })
   })

   this.$bus.on("change_foot",(val)=>{
    this.setState(state=>{
     state.isture=val
     return state
    })
  })
  }

  change_flag(){
    this.setState(state=>{
      state.flag=true
      
      return state
    })
  }
  render() {

    return (
      <BrowserRouter>
      <div className="wrap">
       {this.state.flag && 
       <div>
          < Header></ Header>
        < Nav></ Nav>
        <div className="container">
        <Route exact path="/" component={Imported}></Route>
        <Route exact path="/Internal" component={Internal}></Route>
        <Route exact path="/Driedfd" component={Driedfd}></Route>
        <Route exact path="/Nut" component={Nut}></Route>
        </div>
       </div>
       }
        {this.state.isture ?< Footer  change_flag={this.change_flag.bind(this)}/>:<Payfoot/>}
        {/* {this.state.isture && <Route exact path="/" component={Imported}></Route>} */}
        <Route exact path="/Exchange" component={Exchange}></Route>
        <Route exact path="/Buycart" component={Buycart}></Route>
        <Route exact path="/Member" component={Member}></Route>
        <Route exact path="/Detail" component={Detail}></Route>
      </div>
      </BrowserRouter>
    );
  }
}

export default App;
